<h2>Đinh Thị Thiên Thu</h2>
<form method="POST">
    Min Like :<input type="text"name="min">
    Max Like :<input type="text"name="max">
    Keyword  :<input type="text" name="key">
    <input type="submit"name="submit"value="seach">.<br>
    <?php
    require_once './model/db.php';
    $query = "SELECT * FROM companies";
    $companies = getpage($query);
    ?>
    <td>Company :</td>
    <td><select name="Company">
            <?php foreach ($companies as $company): ?>
                <option value="<?php echo $company['id']; ?>">
                    <?php echo $company['name']; ?>
                </option>
            <?php endforeach; ?> 
        </select>
    </td>
    <td>App :</td>
    <td><select name="app">
            <?php
            require_once './model/db.php';
            $query = "SELECT * FROM apps";
            $apps = getpage($query);
            ?>
            <?php foreach ($apps as $app): ?>
                <option value="<?php echo $app['id']; ?>">
                    <?php echo $app['name']; ?>
                <?php endforeach; ?>
            </option>
        </select>
    </td>

</form>
<?php
require_once 'model/db.php';

$query = "SELECT * FROM pages";
$pages = getPage($query);
?>
<?php if (isset($_POST['submit'])): ?>
    <?php $min = (double) $_POST['min']; ?>
    <?php $max = (double) $_POST['max']; ?>
    <?php $keyword = $_POST['key']; ?>

    <table border ="1">
        <tr>
            <th>Pid</th>
            <th>Image</th>
            <th>ID</th>
            <th>Name</th>
            <th>Username</th>
            <th>Phone</th>
            <th>Like</th>
            <th>Category</th>
            <th>Status</th>
            <th>About</th>

        </tr>
        <?php foreach ($pages as $page): ?>
            <?php if ((int) $_GET . $page['likes'] >= ((int) $_POST['min']) && (int) $_GET . $page['likes'] <= ((int) $_POST['max'])):
                ?>
                <tr>
                    <td><?php echo $page['pid'] ?></td>
                    <td><img src='<?php echo $page['picture'] ?>'></td>
                    <td><?php echo $page['id'] ?></td>
                    <td><?php echo $page['name'] ?></td>
                    <td><?php echo $page['username'] ?></td>
                    <td><?php echo $page['phone'] ?></td>
                    <td><?php echo $page['likes'] ?></td>
                    <td><?php echo $page['category'] ?></td>
                    <td><?php echo $page['status'] ?></td>
                    <td><?php echo $page['about'] ?></td>
                </tr>
            <?php elseif ((strstr($keyword, $page['name']) == 0) && ((int) $page['likes'] >= ((int) $_POST['min'])) &&
                    ((int) $page['likes']) <= ((int) $_POST['max'])):
                ?>
                <tr>
                    <td><?php echo $page['pid'] ?></td>
                    <td><img src='<?php echo $page['picture'] ?>'></td>
                    <td><?php echo $page['id'] ?></td>
                    <td><?php echo $page['name'] ?></td>
                    <td><?php echo $page['username'] ?></td>
                    <td><?php echo $page['phone'] ?></td>
                    <td><?php echo $page['likes'] ?></td>
                    <td><?php echo $page['category'] ?></td>
                    <td><?php echo $page['status'] ?></td>
                    <td><?php echo $page['about'] ?></td>
                </tr>

            <?php endif; ?>

    <?php endforeach; ?>
    </table>
<?php endif; ?>